package licode.unisop.client.vo;

import lombok.Getter;

/**
 * 地址匹配状态
 *
 * @author licode
 */
@Getter
public class SopUrlMatch {
    public static Integer NORMAL = 0;
    // 匹配成功
    public static Integer OK = 1;
    // 禁止访问
    public static Integer DISABLED = 2;
    // 匹配失败
    public static Integer NO_MATCH = 8;
    
    private Integer flag;
    private boolean isLogin;

    public SopUrlMatch() {

    }

    public void setFlag(Integer flag) {
        this.flag = flag;
    }

    public void setLogin(boolean login) {
        isLogin = login;
    }

    public SopUrlMatch(Integer flag, boolean isLogin) {
        this.flag = flag;
        this.isLogin = isLogin;
    }

    public static SopUrlMatch normal(boolean isLogin) {
        return new SopUrlMatch(SopUrlMatch.NORMAL, isLogin);
    }

    public static SopUrlMatch ok(boolean isLogin) {
        return new SopUrlMatch(SopUrlMatch.OK, isLogin);
    }

    public static SopUrlMatch disabled(boolean isLogin) {
        return new SopUrlMatch(SopUrlMatch.DISABLED, isLogin);
    }

    public static SopUrlMatch noMatch(boolean isLogin) {
        return new SopUrlMatch(SopUrlMatch.NO_MATCH, isLogin);
    }

    public Integer flag() {
        return this.flag;
    }

    public boolean isLogin() {
        return this.isLogin;
    }

    public boolean isNormal() {
        return (SopUrlMatch.NORMAL.equals(flag));
    }

    public boolean isOk() {
        return (SopUrlMatch.OK.equals(flag));
    }

    public boolean isDisabled() {
        return (SopUrlMatch.DISABLED.equals(flag));
    }

    public boolean isNoMatch() {
        return (SopUrlMatch.NO_MATCH.equals(flag));
    }

    @Override
    public String toString() {
        return flag + "";
    }
}
